package com.geek.mq.rabbitmq.helloworld;

import com.geek.mq.rabbitmq.constant.RabbitConstant;
import com.geek.mq.rabbitmq.util.RabbitMqUtil;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;
import java.net.URISyntaxException;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.concurrent.TimeoutException;

/**
 * 生产者
 */
public class ProducerHW {

	public static void main(String[] args) throws IOException, TimeoutException {
		Connection connection = RabbitMqUtil.getConnection();
		Channel channel = connection.createChannel();

		/**
		 *  用于绑定队列
		 * 第一个参数：队列名
		 * 第二个参数：
		 */
		channel.queueDeclare(RabbitConstant.RABBITMQ_QUEUE_HELLO_WORLD, false, false, false, null);

		String message = "Hello World";
		channel.basicPublish("", RabbitConstant.RABBITMQ_QUEUE_HELLO_WORLD, null, message.getBytes());

		channel.close();
		connection.close();
	}

}
